package cn.eleven.mapper;

import cn.eleven.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {
    @Select("select user.username," +
            "forum_post.title," +
            "forum_post.content," +
            "forum_post.topic," +
            "forum_post.created_at from user,forum_post" +
            "where user.id = forum_post.user_id " +
            "and user.id = #{id}")
    User getUserById(int id);

    @Select("SELECT * FROM forum_post WHERE user_id = #{userId}")
    User selectByUserId(int userId);
    @Select("SELECT * FROM user WHERE email = #{email}")
    User selectByEmail(String email);
}